/**
 * <b>项目名：</b>oasis-cms<br/>
 * <b>包名：</b>com.bookdao.oasis.cms<br/>
 * <b>文件名：</b>OasisCmsMvcConfig.java<br/>
 * <b>描述：</b><br/>
 * <b>版本信息：</b>v1.0.0<br/>
 * <b>日期：</b>2017年1月8日-下午8:13:10<br/>
 * <b>Copyright (c)</b> 2017智道@版权所有<br/>
 */

package com.bookdao.oasis.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.bookdao.oasis.common.framework.interceptor.AuthInterceptor;
import com.bookdao.oasis.common.spring.SpringBeanUtil;

/**
 * <b>类名称：</b>OasisCmsMvcConfig <br/>
 * <b>类描述：</b><br/>
 * <b>创建人：</b>zhanghj<br/>
 * <b>修改人：</b><br/>
 * <b>修改时间：</b>2017年1月8日 下午8:13:10<br/>
 * <b>修改备注：</b><br/>
 * <b>版本信息：</b>v1.0.0<br/>
 */
@Configuration
//@EnableWebMvc
@ComponentScan("com.bookdao.oasis.cms")
public class OasisCmsMvcConfig extends WebMvcConfigurerAdapter {

	@Bean
	public AuthInterceptor getAuthInterceptor(){
		return new AuthInterceptor();
	}
	/* 
	 * (non-Javadoc)
	 * @see org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter#addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry)
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry){
		registry.addInterceptor(getAuthInterceptor()).addPathPatterns("/**");
	}
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry){
		//1.注释EnableWebMvc 并且注释registry的代码可以访问默认的静态资源
		registry.addResourceHandler("/static/**").addResourceLocations("/static/");
		//registry.addResourceHandler("/static2/**").addResourceLocations("/static2/");
	} 
}
